Skip to content

Rename CLI to 'hf' + reorganize syntax #3229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 23, 2025
Merged

Rename CLI to 'hf' + reorganize syntax #3229

merged 11 commits into from
Jul 23, 2025

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jul 17, 2025

Closes #3224.
Partly inspired by #3225 but I preferred to start from scratch.

Goal is to rename huggingface-cli to hf + harmonize the syntax. We mostly follow a hf <resource> <action> [options] syntax similar to what's done by github CLI https://cli.github.com/manual/gh.

✗ hf --help
usage: hf <command> [<args>]

positional arguments:
  {auth,cache,download,repo,repo-files,upload,upload-large-folder,env,version,lfs-enable-largefiles,lfs-multipart-upload}
                        hf command helpers
    auth                Manage authentication (login, logout, etc.).
    cache               Manage local cache directory.
    download            Download files from the Hub
    repo                Manage repos on the Hub.
    repo-files          Manage files in a repo on the Hub.
    upload              Upload a file or a folder to the Hub. Recommended for single-commit uploads.
    upload-large-folder
                        Upload a large folder to the Hub. Recommended for resumable uploads.
    env                 Print information about the environment.
    version             Print information about the hf version.

options:
  -h, --help            show this help message and exit

Next steps will be to add new commands for a more consistent and feature-complete CLI, but story for another day!

@Wauplin Wauplin changed the title Rename CLI to 'hf' + reorganize them Rename CLI to 'hf' + reorganize syntax Jul 17, 2025
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@huggingface huggingface locked and limited conversation to collaborators Jul 22, 2025
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited for this! hf feels so much more natural than huggingface-cli

One question: wouldn't it make our life simpler during maintenance and to remove the deprecation down the road, to move all commands from commands to cli while keeping a utility to still allow imports from commands, rather than copy-pasting everything?

Keeping two copies means that it's easy for the two to diverge, and I don't think we want that even through the deprecation. If the syntax is too different from the original, feel free to ignore 🤗


Played around with it locally, it works great! When using the deprecated API (like huggingface-cli login, you still get recommendations about the old API, maybe worth recommending only new APIs everywhere? But not key for this PR.

Ex:

- A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
+ A token is already saved on your machine. Run `hf auth whoami` to get more information or `hf auth logout` if you want to log out.

@huggingface huggingface unlocked this conversation Jul 23, 2025
@julien-c
Copy link
Member

BTW, would brew (for instance) be ok with having two aliases (the current huggingface-cli and hf)? Might be worth checking with them

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 23, 2025

Played around with it locally, it works great! When using the deprecated API (like huggingface-cli login, you still get recommendations about the old API, maybe worth recommending only new APIs everywhere? But not key for this PR.

@LysandreJik I've updated all the documentation and tips to promote hf instead of huggingface-cli 6d820c4 (retrospectively I should have done it in a follow-up PR to keep this one small-ish but too late...)

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 23, 2025

One question: wouldn't it make our life simpler during maintenance and to remove the deprecation down the road, to move all commands from commands to cli while keeping a utility to still allow imports from commands, rather than copy-pasting everything?

Keeping two copies means that it's easy for the two to diverge, and I don't think we want that even through the deprecation. If the syntax is too different from the original, feel free to ignore 🤗

@LysandreJik as mentioned in DMs, I prefer to stick with the "duplicated code" approach. Even if it's not the cleanest solution, I see a few benefits to it:

  • we don't touch anything to existing logic => guarantees we don't brake anything
  • CLIs have slightly diverged in syntax. If I want to keep a unified logic it makes it slightly annoying to handle both in a clean way
  • having separated code makes it easy to add new commands to the new CLI without adding them to the old CLI (which we don't want to extend in order to force users to use the new one)
    • hopefully we won't change much of the legacy CLI. If there are severe bugs, we will fix them but otherwise we will simply leave it as it is now without maintaining/adding new stuff to it

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 23, 2025

BTW, would brew (for instance) be ok with having two aliases (the current huggingface-cli and hf)? Might be worth checking with them

Gentle ping to @singingwolfboy on this :)

For context, we are switching the HF CLI from huggingface-cli to hf with a slightly improved syntax. For example huggingface-cli login becomes hf auth login to be closer to the well-designed GitHub's CLI. In practice, both CLIs will exist at the same time. The legacy one huggingface-cli is deprecated and redirects to hf but will still be functional. We will remove it in the future but only after a very long deprecation cycle. We promote only hf in our docs.

@singingwolfboy my questions are now: would brew be able to support 2 command lines like this? Or would it simply be a separate brew install hf command? Also the tests in this script will probably break when we release this (huggingface-cli whoami => hf auth whoami + if using legacy CLI you'll get an additional warning message). Let me know if we can help in any way 🤗

(gentle ping to @abitrolly who has maintained the brew script lately)

Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR @Wauplin! i mainly reviewed the API and tested the commands locally and it looks great, i love it! 🔥

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 23, 2025

Thanks everyone! I'll merge this one now.

About brew (#3229 (comment)), I kept the previous huggingface-cli docs for now and we can adapt in a future PR. I don't want to make this one bigger than what it is now ^^

@Wauplin Wauplin merged commit e981dea into main Jul 23, 2025
25 checks passed
@Wauplin Wauplin deleted the 3224-hf-cli branch July 23, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smoothly switch CLI to hf
5 participants